In [1]:
using XSim
using Distributions
using StatsFuns
using Gadfly
using Random
using Printf
using StatsBase
using LinearAlgebra
using JWAS
using DataFrames
using DelimitedFiles
using Cairo
using Fontconfig
using GLM
using PlotlyJS

The WebIO Jupyter extension was not detected. See the WebIO Jupyter integration documentation for more information.

In [2]:
include("Functions.jl")
Out[2]:
SNP_SNP_GWAS2 (generic function with 2 methods)
In [3]:
Random.seed!(95616)
numChr,numLoci,chrLength,mutRate = 1,3020,1.0,2.5e-5  # Mutation rate was 2.5*10−5 during the historical generations
locusInt  = chrLength/numLoci
mapPos   = collect(0:locusInt:(chrLength-0.0001))  #Uniform position
geneFreq   = fill(0.5,numLoci)  # initial gene frequency 0.5
XSim.build_genome(numChr,chrLength,numLoci,geneFreq,mapPos,mutRate)
In [4]:
sireSizeFounder = 200
damSizeFounder = 200
sires = sampleFounders(sireSizeFounder)
dams  = sampleFounders(damSizeFounder);
Sampling 200 animals into base population.
Sampling 200 animals into base population.
In [5]:
ngen,popSize = 500,400
sires1,dams1,gen1 = sampleRan(popSize, ngen, sires, dams);
Generation     2: sampling   200 males and   200 females
Generation     3: sampling   200 males and   200 females
Generation     4: sampling   200 males and   200 females
Generation     5: sampling   200 males and   200 females
Generation     6: sampling   200 males and   200 females
Generation     7: sampling   200 males and   200 females
Generation     8: sampling   200 males and   200 females
Generation     9: sampling   200 males and   200 females
Generation    10: sampling   200 males and   200 females
Generation    11: sampling   200 males and   200 females
Generation    12: sampling   200 males and   200 females
Generation    13: sampling   200 males and   200 females
Generation    14: sampling   200 males and   200 females
Generation    15: sampling   200 males and   200 females
Generation    16: sampling   200 males and   200 females
Generation    17: sampling   200 males and   200 females
Generation    18: sampling   200 males and   200 females
Generation    19: sampling   200 males and   200 females
Generation    20: sampling   200 males and   200 females
Generation    21: sampling   200 males and   200 females
Generation    22: sampling   200 males and   200 females
Generation    23: sampling   200 males and   200 females
Generation    24: sampling   200 males and   200 females
Generation    25: sampling   200 males and   200 females
Generation    26: sampling   200 males and   200 females
Generation    27: sampling   200 males and   200 females
Generation    28: sampling   200 males and   200 females
Generation    29: sampling   200 males and   200 females
Generation    30: sampling   200 males and   200 females
Generation    31: sampling   200 males and   200 females
Generation    32: sampling   200 males and   200 females
Generation    33: sampling   200 males and   200 females
Generation    34: sampling   200 males and   200 females
Generation    35: sampling   200 males and   200 females
Generation    36: sampling   200 males and   200 females
Generation    37: sampling   200 males and   200 females
Generation    38: sampling   200 males and   200 females
Generation    39: sampling   200 males and   200 females
Generation    40: sampling   200 males and   200 females
Generation    41: sampling   200 males and   200 females
Generation    42: sampling   200 males and   200 females
Generation    43: sampling   200 males and   200 females
Generation    44: sampling   200 males and   200 females
Generation    45: sampling   200 males and   200 females
Generation    46: sampling   200 males and   200 females
Generation    47: sampling   200 males and   200 females
Generation    48: sampling   200 males and   200 females
Generation    49: sampling   200 males and   200 females
Generation    50: sampling   200 males and   200 females
Generation    51: sampling   200 males and   200 females
Generation    52: sampling   200 males and   200 females
Generation    53: sampling   200 males and   200 females
Generation    54: sampling   200 males and   200 females
Generation    55: sampling   200 males and   200 females
Generation    56: sampling   200 males and   200 females
Generation    57: sampling   200 males and   200 females
Generation    58: sampling   200 males and   200 females
Generation    59: sampling   200 males and   200 females
Generation    60: sampling   200 males and   200 females
Generation    61: sampling   200 males and   200 females
Generation    62: sampling   200 males and   200 females
Generation    63: sampling   200 males and   200 females
Generation    64: sampling   200 males and   200 females
Generation    65: sampling   200 males and   200 females
Generation    66: sampling   200 males and   200 females
Generation    67: sampling   200 males and   200 females
Generation    68: sampling   200 males and   200 females
Generation    69: sampling   200 males and   200 females
Generation    70: sampling   200 males and   200 females
Generation    71: sampling   200 males and   200 females
Generation    72: sampling   200 males and   200 females
Generation    73: sampling   200 males and   200 females
Generation    74: sampling   200 males and   200 females
Generation    75: sampling   200 males and   200 females
Generation    76: sampling   200 males and   200 females
Generation    77: sampling   200 males and   200 females
Generation    78: sampling   200 males and   200 females
Generation    79: sampling   200 males and   200 females
Generation    80: sampling   200 males and   200 females
Generation    81: sampling   200 males and   200 females
Generation    82: sampling   200 males and   200 females
Generation    83: sampling   200 males and   200 females
Generation    84: sampling   200 males and   200 females
Generation    85: sampling   200 males and   200 females
Generation    86: sampling   200 males and   200 females
Generation    87: sampling   200 males and   200 females
Generation    88: sampling   200 males and   200 females
Generation    89: sampling   200 males and   200 females
Generation    90: sampling   200 males and   200 females
Generation    91: sampling   200 males and   200 females
Generation    92: sampling   200 males and   200 females
Generation    93: sampling   200 males and   200 females
Generation    94: sampling   200 males and   200 females
Generation    95: sampling   200 males and   200 females
Generation    96: sampling   200 males and   200 females
Generation    97: sampling   200 males and   200 females
Generation    98: sampling   200 males and   200 females
Generation    99: sampling   200 males and   200 females
Generation   100: sampling   200 males and   200 females
Generation   101: sampling   200 males and   200 females
Generation   102: sampling   200 males and   200 females
Generation   103: sampling   200 males and   200 females
Generation   104: sampling   200 males and   200 females
Generation   105: sampling   200 males and   200 females
Generation   106: sampling   200 males and   200 females
Generation   107: sampling   200 males and   200 females
Generation   108: sampling   200 males and   200 females
Generation   109: sampling   200 males and   200 females
Generation   110: sampling   200 males and   200 females
Generation   111: sampling   200 males and   200 females
Generation   112: sampling   200 males and   200 females
Generation   113: sampling   200 males and   200 females
Generation   114: sampling   200 males and   200 females
Generation   115: sampling   200 males and   200 females
Generation   116: sampling   200 males and   200 females
Generation   117: sampling   200 males and   200 females
Generation   118: sampling   200 males and   200 females
Generation   119: sampling   200 males and   200 females
Generation   120: sampling   200 males and   200 females
Generation   121: sampling   200 males and   200 females
Generation   122: sampling   200 males and   200 females
Generation   123: sampling   200 males and   200 females
Generation   124: sampling   200 males and   200 females
Generation   125: sampling   200 males and   200 females
Generation   126: sampling   200 males and   200 females
Generation   127: sampling   200 males and   200 females
Generation   128: sampling   200 males and   200 females
Generation   129: sampling   200 males and   200 females
Generation   130: sampling   200 males and   200 females
Generation   131: sampling   200 males and   200 females
Generation   132: sampling   200 males and   200 females
Generation   133: sampling   200 males and   200 females
Generation   134: sampling   200 males and   200 females
Generation   135: sampling   200 males and   200 females
Generation   136: sampling   200 males and   200 females
Generation   137: sampling   200 males and   200 females
Generation   138: sampling   200 males and   200 females
Generation   139: sampling   200 males and   200 females
Generation   140: sampling   200 males and   200 females
Generation   141: sampling   200 males and   200 females
Generation   142: sampling   200 males and   200 females
Generation   143: sampling   200 males and   200 females
Generation   144: sampling   200 males and   200 females
Generation   145: sampling   200 males and   200 females
Generation   146: sampling   200 males and   200 females
Generation   147: sampling   200 males and   200 females
Generation   148: sampling   200 males and   200 females
Generation   149: sampling   200 males and   200 females
Generation   150: sampling   200 males and   200 females
Generation   151: sampling   200 males and   200 females
Generation   152: sampling   200 males and   200 females
Generation   153: sampling   200 males and   200 females
Generation   154: sampling   200 males and   200 females
Generation   155: sampling   200 males and   200 females
Generation   156: sampling   200 males and   200 females
Generation   157: sampling   200 males and   200 females
Generation   158: sampling   200 males and   200 females
Generation   159: sampling   200 males and   200 females
Generation   160: sampling   200 males and   200 females
Generation   161: sampling   200 males and   200 females
Generation   162: sampling   200 males and   200 females
Generation   163: sampling   200 males and   200 females
Generation   164: sampling   200 males and   200 females
Generation   165: sampling   200 males and   200 females
Generation   166: sampling   200 males and   200 females
Generation   167: sampling   200 males and   200 females
Generation   168: sampling   200 males and   200 females
Generation   169: sampling   200 males and   200 females
Generation   170: sampling   200 males and   200 females
Generation   171: sampling   200 males and   200 females
Generation   172: sampling   200 males and   200 females
Generation   173: sampling   200 males and   200 females
Generation   174: sampling   200 males and   200 females
Generation   175: sampling   200 males and   200 females
Generation   176: sampling   200 males and   200 females
Generation   177: sampling   200 males and   200 females
Generation   178: sampling   200 males and   200 females
Generation   179: sampling   200 males and   200 females
Generation   180: sampling   200 males and   200 females
Generation   181: sampling   200 males and   200 females
Generation   182: sampling   200 males and   200 females
Generation   183: sampling   200 males and   200 females
Generation   184: sampling   200 males and   200 females
Generation   185: sampling   200 males and   200 females
Generation   186: sampling   200 males and   200 females
Generation   187: sampling   200 males and   200 females
Generation   188: sampling   200 males and   200 females
Generation   189: sampling   200 males and   200 females
Generation   190: sampling   200 males and   200 females
Generation   191: sampling   200 males and   200 females
Generation   192: sampling   200 males and   200 females
Generation   193: sampling   200 males and   200 females
Generation   194: sampling   200 males and   200 females
Generation   195: sampling   200 males and   200 females
Generation   196: sampling   200 males and   200 females
Generation   197: sampling   200 males and   200 females
Generation   198: sampling   200 males and   200 females
Generation   199: sampling   200 males and   200 females
Generation   200: sampling   200 males and   200 females
Generation   201: sampling   200 males and   200 females
Generation   202: sampling   200 males and   200 females
Generation   203: sampling   200 males and   200 females
Generation   204: sampling   200 males and   200 females
Generation   205: sampling   200 males and   200 females
Generation   206: sampling   200 males and   200 females
Generation   207: sampling   200 males and   200 females
Generation   208: sampling   200 males and   200 females
Generation   209: sampling   200 males and   200 females
Generation   210: sampling   200 males and   200 females
Generation   211: sampling   200 males and   200 females
Generation   212: sampling   200 males and   200 females
Generation   213: sampling   200 males and   200 females
Generation   214: sampling   200 males and   200 females
Generation   215: sampling   200 males and   200 females
Generation   216: sampling   200 males and   200 females
Generation   217: sampling   200 males and   200 females
Generation   218: sampling   200 males and   200 females
Generation   219: sampling   200 males and   200 females
Generation   220: sampling   200 males and   200 females
Generation   221: sampling   200 males and   200 females
Generation   222: sampling   200 males and   200 females
Generation   223: sampling   200 males and   200 females
Generation   224: sampling   200 males and   200 females
Generation   225: sampling   200 males and   200 females
Generation   226: sampling   200 males and   200 females
Generation   227: sampling   200 males and   200 females
Generation   228: sampling   200 males and   200 females
Generation   229: sampling   200 males and   200 females
Generation   230: sampling   200 males and   200 females
Generation   231: sampling   200 males and   200 females
Generation   232: sampling   200 males and   200 females
Generation   233: sampling   200 males and   200 females
Generation   234: sampling   200 males and   200 females
Generation   235: sampling   200 males and   200 females
Generation   236: sampling   200 males and   200 females
Generation   237: sampling   200 males and   200 females
Generation   238: sampling   200 males and   200 females
Generation   239: sampling   200 males and   200 females
Generation   240: sampling   200 males and   200 females
Generation   241: sampling   200 males and   200 females
Generation   242: sampling   200 males and   200 females
Generation   243: sampling   200 males and   200 females
Generation   244: sampling   200 males and   200 females
Generation   245: sampling   200 males and   200 females
Generation   246: sampling   200 males and   200 females
Generation   247: sampling   200 males and   200 females
Generation   248: sampling   200 males and   200 females
Generation   249: sampling   200 males and   200 females
Generation   250: sampling   200 males and   200 females
Generation   251: sampling   200 males and   200 females
Generation   252: sampling   200 males and   200 females
Generation   253: sampling   200 males and   200 females
Generation   254: sampling   200 males and   200 females
Generation   255: sampling   200 males and   200 females
Generation   256: sampling   200 males and   200 females
Generation   257: sampling   200 males and   200 females
Generation   258: sampling   200 males and   200 females
Generation   259: sampling   200 males and   200 females
Generation   260: sampling   200 males and   200 females
Generation   261: sampling   200 males and   200 females
Generation   262: sampling   200 males and   200 females
Generation   263: sampling   200 males and   200 females
Generation   264: sampling   200 males and   200 females
Generation   265: sampling   200 males and   200 females
Generation   266: sampling   200 males and   200 females
Generation   267: sampling   200 males and   200 females
Generation   268: sampling   200 males and   200 females
Generation   269: sampling   200 males and   200 females
Generation   270: sampling   200 males and   200 females
Generation   271: sampling   200 males and   200 females
Generation   272: sampling   200 males and   200 females
Generation   273: sampling   200 males and   200 females
Generation   274: sampling   200 males and   200 females
Generation   275: sampling   200 males and   200 females
Generation   276: sampling   200 males and   200 females
Generation   277: sampling   200 males and   200 females
Generation   278: sampling   200 males and   200 females
Generation   279: sampling   200 males and   200 females
Generation   280: sampling   200 males and   200 females
Generation   281: sampling   200 males and   200 females
Generation   282: sampling   200 males and   200 females
Generation   283: sampling   200 males and   200 females
Generation   284: sampling   200 males and   200 females
Generation   285: sampling   200 males and   200 females
Generation   286: sampling   200 males and   200 females
Generation   287: sampling   200 males and   200 females
Generation   288: sampling   200 males and   200 females
Generation   289: sampling   200 males and   200 females
Generation   290: sampling   200 males and   200 females
Generation   291: sampling   200 males and   200 females
Generation   292: sampling   200 males and   200 females
Generation   293: sampling   200 males and   200 females
Generation   294: sampling   200 males and   200 females
Generation   295: sampling   200 males and   200 females
Generation   296: sampling   200 males and   200 females
Generation   297: sampling   200 males and   200 females
Generation   298: sampling   200 males and   200 females
Generation   299: sampling   200 males and   200 females
Generation   300: sampling   200 males and   200 females
Generation   301: sampling   200 males and   200 females
Generation   302: sampling   200 males and   200 females
Generation   303: sampling   200 males and   200 females
Generation   304: sampling   200 males and   200 females
Generation   305: sampling   200 males and   200 females
Generation   306: sampling   200 males and   200 females
Generation   307: sampling   200 males and   200 females
Generation   308: sampling   200 males and   200 females
Generation   309: sampling   200 males and   200 females
Generation   310: sampling   200 males and   200 females
Generation   311: sampling   200 males and   200 females
Generation   312: sampling   200 males and   200 females
Generation   313: sampling   200 males and   200 females
Generation   314: sampling   200 males and   200 females
Generation   315: sampling   200 males and   200 females
Generation   316: sampling   200 males and   200 females
Generation   317: sampling   200 males and   200 females
Generation   318: sampling   200 males and   200 females
Generation   319: sampling   200 males and   200 females
Generation   320: sampling   200 males and   200 females
Generation   321: sampling   200 males and   200 females
Generation   322: sampling   200 males and   200 females
Generation   323: sampling   200 males and   200 females
Generation   324: sampling   200 males and   200 females
Generation   325: sampling   200 males and   200 females
Generation   326: sampling   200 males and   200 females
Generation   327: sampling   200 males and   200 females
Generation   328: sampling   200 males and   200 females
Generation   329: sampling   200 males and   200 females
Generation   330: sampling   200 males and   200 females
Generation   331: sampling   200 males and   200 females
Generation   332: sampling   200 males and   200 females
Generation   333: sampling   200 males and   200 females
Generation   334: sampling   200 males and   200 females
Generation   335: sampling   200 males and   200 females
Generation   336: sampling   200 males and   200 females
Generation   337: sampling   200 males and   200 females
Generation   338: sampling   200 males and   200 females
Generation   339: sampling   200 males and   200 females
Generation   340: sampling   200 males and   200 females
Generation   341: sampling   200 males and   200 females
Generation   342: sampling   200 males and   200 females
Generation   343: sampling   200 males and   200 females
Generation   344: sampling   200 males and   200 females
Generation   345: sampling   200 males and   200 females
Generation   346: sampling   200 males and   200 females
Generation   347: sampling   200 males and   200 females
Generation   348: sampling   200 males and   200 females
Generation   349: sampling   200 males and   200 females
Generation   350: sampling   200 males and   200 females
Generation   351: sampling   200 males and   200 females
Generation   352: sampling   200 males and   200 females
Generation   353: sampling   200 males and   200 females
Generation   354: sampling   200 males and   200 females
Generation   355: sampling   200 males and   200 females
Generation   356: sampling   200 males and   200 females
Generation   357: sampling   200 males and   200 females
Generation   358: sampling   200 males and   200 females
Generation   359: sampling   200 males and   200 females
Generation   360: sampling   200 males and   200 females
Generation   361: sampling   200 males and   200 females
Generation   362: sampling   200 males and   200 females
Generation   363: sampling   200 males and   200 females
Generation   364: sampling   200 males and   200 females
Generation   365: sampling   200 males and   200 females
Generation   366: sampling   200 males and   200 females
Generation   367: sampling   200 males and   200 females
Generation   368: sampling   200 males and   200 females
Generation   369: sampling   200 males and   200 females
Generation   370: sampling   200 males and   200 females
Generation   371: sampling   200 males and   200 females
Generation   372: sampling   200 males and   200 females
Generation   373: sampling   200 males and   200 females
Generation   374: sampling   200 males and   200 females
Generation   375: sampling   200 males and   200 females
Generation   376: sampling   200 males and   200 females
Generation   377: sampling   200 males and   200 females
Generation   378: sampling   200 males and   200 females
Generation   379: sampling   200 males and   200 females
Generation   380: sampling   200 males and   200 females
Generation   381: sampling   200 males and   200 females
Generation   382: sampling   200 males and   200 females
Generation   383: sampling   200 males and   200 females
Generation   384: sampling   200 males and   200 females
Generation   385: sampling   200 males and   200 females
Generation   386: sampling   200 males and   200 females
Generation   387: sampling   200 males and   200 females
Generation   388: sampling   200 males and   200 females
Generation   389: sampling   200 males and   200 females
Generation   390: sampling   200 males and   200 females
Generation   391: sampling   200 males and   200 females
Generation   392: sampling   200 males and   200 females
Generation   393: sampling   200 males and   200 females
Generation   394: sampling   200 males and   200 females
Generation   395: sampling   200 males and   200 females
Generation   396: sampling   200 males and   200 females
Generation   397: sampling   200 males and   200 females
Generation   398: sampling   200 males and   200 females
Generation   399: sampling   200 males and   200 females
Generation   400: sampling   200 males and   200 females
Generation   401: sampling   200 males and   200 females
Generation   402: sampling   200 males and   200 females
Generation   403: sampling   200 males and   200 females
Generation   404: sampling   200 males and   200 females
Generation   405: sampling   200 males and   200 females
Generation   406: sampling   200 males and   200 females
Generation   407: sampling   200 males and   200 females
Generation   408: sampling   200 males and   200 females
Generation   409: sampling   200 males and   200 females
Generation   410: sampling   200 males and   200 females
Generation   411: sampling   200 males and   200 females
Generation   412: sampling   200 males and   200 females
Generation   413: sampling   200 males and   200 females
Generation   414: sampling   200 males and   200 females
Generation   415: sampling   200 males and   200 females
Generation   416: sampling   200 males and   200 females
Generation   417: sampling   200 males and   200 females
Generation   418: sampling   200 males and   200 females
Generation   419: sampling   200 males and   200 females
Generation   420: sampling   200 males and   200 females
Generation   421: sampling   200 males and   200 females
Generation   422: sampling   200 males and   200 females
Generation   423: sampling   200 males and   200 females
Generation   424: sampling   200 males and   200 females
Generation   425: sampling   200 males and   200 females
Generation   426: sampling   200 males and   200 females
Generation   427: sampling   200 males and   200 females
Generation   428: sampling   200 males and   200 females
Generation   429: sampling   200 males and   200 females
Generation   430: sampling   200 males and   200 females
Generation   431: sampling   200 males and   200 females
Generation   432: sampling   200 males and   200 females
Generation   433: sampling   200 males and   200 females
Generation   434: sampling   200 males and   200 females
Generation   435: sampling   200 males and   200 females
Generation   436: sampling   200 males and   200 females
Generation   437: sampling   200 males and   200 females
Generation   438: sampling   200 males and   200 females
Generation   439: sampling   200 males and   200 females
Generation   440: sampling   200 males and   200 females
Generation   441: sampling   200 males and   200 females
Generation   442: sampling   200 males and   200 females
Generation   443: sampling   200 males and   200 females
Generation   444: sampling   200 males and   200 females
Generation   445: sampling   200 males and   200 females
Generation   446: sampling   200 males and   200 females
Generation   447: sampling   200 males and   200 females
Generation   448: sampling   200 males and   200 females
Generation   449: sampling   200 males and   200 females
Generation   450: sampling   200 males and   200 females
Generation   451: sampling   200 males and   200 females
Generation   452: sampling   200 males and   200 females
Generation   453: sampling   200 males and   200 females
Generation   454: sampling   200 males and   200 females
Generation   455: sampling   200 males and   200 females
Generation   456: sampling   200 males and   200 females
Generation   457: sampling   200 males and   200 females
Generation   458: sampling   200 males and   200 females
Generation   459: sampling   200 males and   200 females
Generation   460: sampling   200 males and   200 females
Generation   461: sampling   200 males and   200 females
Generation   462: sampling   200 males and   200 females
Generation   463: sampling   200 males and   200 females
Generation   464: sampling   200 males and   200 females
Generation   465: sampling   200 males and   200 females
Generation   466: sampling   200 males and   200 females
Generation   467: sampling   200 males and   200 females
Generation   468: sampling   200 males and   200 females
Generation   469: sampling   200 males and   200 females
Generation   470: sampling   200 males and   200 females
Generation   471: sampling   200 males and   200 females
Generation   472: sampling   200 males and   200 females
Generation   473: sampling   200 males and   200 females
Generation   474: sampling   200 males and   200 females
Generation   475: sampling   200 males and   200 females
Generation   476: sampling   200 males and   200 females
Generation   477: sampling   200 males and   200 females
Generation   478: sampling   200 males and   200 females
Generation   479: sampling   200 males and   200 females
Generation   480: sampling   200 males and   200 females
Generation   481: sampling   200 males and   200 females
Generation   482: sampling   200 males and   200 females
Generation   483: sampling   200 males and   200 females
Generation   484: sampling   200 males and   200 females
Generation   485: sampling   200 males and   200 females
Generation   486: sampling   200 males and   200 females
Generation   487: sampling   200 males and   200 females
Generation   488: sampling   200 males and   200 females
Generation   489: sampling   200 males and   200 females
Generation   490: sampling   200 males and   200 females
Generation   491: sampling   200 males and   200 females
Generation   492: sampling   200 males and   200 females
Generation   493: sampling   200 males and   200 females
Generation   494: sampling   200 males and   200 females
Generation   495: sampling   200 males and   200 females
Generation   496: sampling   200 males and   200 females
Generation   497: sampling   200 males and   200 females
Generation   498: sampling   200 males and   200 females
Generation   499: sampling   200 males and   200 females
Generation   500: sampling   200 males and   200 females
Generation   501: sampling   200 males and   200 females
In [6]:
ngen,popSize = 1,60
sires1,dams1,gen2 = sampleRan(popSize, ngen, sires1, dams1, gen = gen1);
Generation   502: sampling    30 males and    30 females
In [7]:
ngen,popSize = 1,600
sires1_2,dams1_2,gen2 = sampleRan(popSize, ngen, sires1, dams1, gen = gen1);
Generation   502: sampling   300 males and   300 females
In [8]:
ngen,popSize = 1,1800
siresA1,damsA1,genA1 = sampleRan(popSize, ngen, sires1, dams1_2,gen = gen2)
siresA2,damsA2,genA2 = sampleRan(popSize, ngen, siresA1, damsA1,gen = genA1)
siresA3,damsA3,genA3 = sampleRan(popSize, ngen, siresA2, damsA2,gen = genA2)
siresA4,damsA4,genA4 = sampleRan(popSize, ngen, siresA3, damsA3,gen = genA3)
siresA5,damsA5,genA5 = sampleRan(popSize, ngen, siresA4, damsA4,gen = genA4)
siresA6,damsA6,genA6 = sampleRan(popSize, ngen, siresA5, damsA5,gen = genA5);
Generation   503: sampling   900 males and   900 females
Generation   504: sampling   900 males and   900 females
Generation   505: sampling   900 males and   900 females
Generation   506: sampling   900 males and   900 females
Generation   507: sampling   900 males and   900 females
Generation   508: sampling   900 males and   900 females
In [9]:
animals4 = concatCohorts(siresA4,damsA4)
animals5 = concatCohorts(siresA5,damsA5)
animals6 = concatCohorts(siresA6,damsA6)
#markers
M4 = getOurGenotypes(animals4)
M5 = getOurGenotypes(animals5)
M6 = getOurGenotypes(animals6)
M = [
     M4
     M5
     M6
    ]
#pedigrees
pedigree4 = getPedigree(animals4)
pedigree5 = getPedigree(animals5)
pedigree6 = getPedigree(animals6)
pedigree = [
            pedigree4
            pedigree5
            pedigree6
            ];
In [10]:
k  = size(M,2)
QTLa = 20     # AddQTL
QTLd = 6      # Dominant SNP 
SNPpairs = 3  # SNP–SNP pairs
QTLPos = sample(1:k,QTLa,replace=false)
mrkPos = deleteat!(collect(1:k),sort(QTLPos))
Qa = M[:,sort(QTLPos)]
X = M[:,mrkPos]
newQTLPos = sort(QTLPos) .- (1:QTLa)  # Position of QTL in marker matrix
@printf "The number of additive QTL = %5i  \n" nQTL = size(Qa,2)
@printf "The number of dominant QTL = %5i  \n" QTLd
@printf "The number of epistatic pairs = %5i  \n" SNPpairs
@printf "The maximum MAF = %.2f  \n" maximum(maf(X))
@printf "The number of markers = %5i  \n" nMarkers = size(X,2)
@printf "The number of phenotypic observations = %5i  \n" nObs = size(Qa,1)
The number of additive QTL =    20  
The number of dominant QTL =     6  
The number of epistatic pairs =     3  
The maximum MAF = 0.50  
The number of markers =  3000  
The number of phenotypic observations =  5400  
In [11]:
α = rand(Gamma(0.4),QTLa) .* sample([-1,1],QTLa);  #scaling parameter α and shape parameter β
In [12]:
d, SortQTLDompos, SortQTLpos = Dominant(QTLPos,QTLd,α);
In [13]:
epistaticQTLPos, epi_coef, epi_combinations = epistatic(QTLPos, SNPpairs);
In [14]:
p = getaf(Qa)
#set fixed allele frequencies to an extreme frequency, so that the algorithm in epi() still works for all loci
p[ p .== 1.0 ] .= 0.99999
p[ p .== 0.0 ] .= 0.00001
#compute genotype frequencies from random mating
gfreq = gf(p,p)
#get epistatic effects
epimodel = "interaction"
epi_vars, epi_effects  = epi(gfreq, p, epi_coef, α, epimodel, epi_combinations);
In [15]:
#get alphas and ds
Newd = zeros(nQTL)
DominQTLpos = findall(x->x in SortQTLDompos, SortQTLpos)
Newd[DominQTLpos] .= d
alphas, ds = get_effects(α,Newd,p,epi_combinations, epi_effects);
Computing orthogonal alphas and ds
In [16]:
#compute noia matrices
noia, noia_dom = make_noia(Qa);
Creating NOIA matrices..
Done creating NOIA matrices!
In [17]:
#breeding values and dominance deviations
simbv = noia * alphas
simdom = noia_dom * ds;
In [18]:
aa = epistaticCom(noia, epi_combinations, noia_dom, nObs, "interaction");
In [19]:
simtgv = simbv + simdom + aa
#### phenotypes ####
resVar = var(simtgv)
resid = rand(Normal(0,sqrt(resVar)), nObs)
pheno = simtgv .+ resid;
In [20]:
QTLPosIndex = [SortQTLpos newQTLPos]
SortQTLDompos = TruePosDom(SortQTLDompos,QTLPosIndex)
sortepistaticQTLPos = TruePosEpis(epistaticQTLPos,QTLPosIndex);

Correlation coefficient solution¶

In [21]:
M = Float64.(X)
r_xy_t,df1 = SNP_pairs_method(M,M,pheno)  #PartialCor for Only Epistasis, DF for Only Epistasis
Out[21]:
([-0.05650086926544551 -0.03074614657813051 … -0.05064146356713942 -0.04762327418589558; -0.03074614657813051 0.03582792866936622 … 0.03511196668787172 0.03195559134667626; … ; -0.05064146356713942 0.03511196668787172 … 0.002779950873527375 0.004374186124885298; -0.04762327418589558 0.03195559134667626 … 0.004374186124885298 0.006950525613016603], 5398)
In [22]:
pval = matrixPval(r_xy_t, df1)
Out[22]:
3000×3000 Matrix{Float64}:
 3.26276e-5   0.0238596    1.08431e-5   …  1.0  0.000196948  0.000463937
 0.0238596    0.00846244   0.0300994       1.0  0.00986887   0.0188592
 1.08431e-5   0.0300994    0.00801672      1.0  0.346026     0.422355
 0.000220582  3.06087e-5   0.246263        1.0  0.244515     0.178692
 1.71913e-5   0.472738     0.0179864       1.0  0.603194     0.700326
 8.6743e-5    0.000612875  0.946195     …  1.0  0.352451     0.352859
 2.5291e-5    0.00189917   0.023175        1.0  0.590832     0.476482
 5.30931e-5   0.764053     0.00134264      1.0  0.0533984    0.120923
 0.000485651  0.00343189   0.0361447       1.0  0.127692     0.113963
 1.0          1.0          1.0             1.0  1.0          1.0
 7.81692e-6   0.00760077   0.029757     …  1.0  0.51388      0.361548
 9.38945e-6   0.0557643    0.00382166      1.0  0.674792     0.486168
 0.000120194  0.39184      0.179628        1.0  0.650519     0.678125
 ⋮                                      ⋱                    
 0.00104639   0.55618      0.00981834      1.0  0.618162     0.53875
 0.000154061  0.180999     0.00206343      1.0  0.797577     0.712539
 0.000907312  0.000215462  0.675013     …  1.0  0.21579      0.167682
 2.5291e-5    0.00199023   0.023175        1.0  0.652038     0.532731
 0.145266     0.125078     0.717841        1.0  0.0408994    0.0705121
 0.0817822    0.256835     0.324379        1.0  0.18359      0.244266
 4.06621e-5   0.00570751   0.0835019       1.0  0.835219     0.718804
 7.48709e-5   0.336182     0.000592498  …  1.0  0.887841     0.752398
 2.5291e-5    0.00192959   0.023175        1.0  0.594003     0.479391
 1.0          1.0          1.0             1.0  1.0          1.0
 0.000196948  0.00986887   0.346026        1.0  0.838168     0.747935
 0.000463937  0.0188592    0.422355        1.0  0.747935     0.6096
In [23]:
corrThreshold = p2c(1, df1)
Out[23]:
0.004199543506596346
In [24]:
index = findall(x -> abs.(x) .> corrThreshold,r_xy_t)
Out[24]:
6643744-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 1)
 CartesianIndex(2, 1)
 CartesianIndex(3, 1)
 CartesianIndex(4, 1)
 CartesianIndex(5, 1)
 CartesianIndex(6, 1)
 CartesianIndex(7, 1)
 CartesianIndex(8, 1)
 CartesianIndex(9, 1)
 CartesianIndex(11, 1)
 CartesianIndex(12, 1)
 CartesianIndex(13, 1)
 CartesianIndex(14, 1)
 ⋮
 CartesianIndex(2988, 3000)
 CartesianIndex(2989, 3000)
 CartesianIndex(2990, 3000)
 CartesianIndex(2991, 3000)
 CartesianIndex(2992, 3000)
 CartesianIndex(2993, 3000)
 CartesianIndex(2994, 3000)
 CartesianIndex(2995, 3000)
 CartesianIndex(2996, 3000)
 CartesianIndex(2997, 3000)
 CartesianIndex(2999, 3000)
 CartesianIndex(3000, 3000)
In [25]:
a = getindex.(index, 1)
b = getindex.(index, 2);
In [26]:
pvalue = matrixPval(r_xy_t[index] , df1)
Out[26]:
6643744-element Vector{Float64}:
 3.262756850563875e-5
 0.023859621889714466
 1.0843139621297126e-5
 0.00022058185347884063
 1.719127491495165e-5
 8.674298930277935e-5
 2.529104353321543e-5
 5.3093100388590386e-5
 0.0004856514767499487
 7.816917126923784e-6
 9.389451693486706e-6
 0.00012019372539295858
 0.0002881683721154271
 ⋮
 0.15746324974925496
 0.5387503807358489
 0.712539319698283
 0.16768179869124822
 0.5327307627198965
 0.07051210773264582
 0.24426603530042534
 0.7188041358360613
 0.7523983005226484
 0.47939067143604674
 0.7479354369571443
 0.6095995476153828
In [27]:
Pvalue_mlog10 = -log10.(pvalue)
Out[27]:
6643744-element Vector{Float64}:
 4.4864152898017755
 1.6223364430006184
 4.964844950013266
 3.6564302183607658
 4.764691914587121
 4.061765615443749
 4.597033250870413
 4.274961913153066
 3.3136752863405654
 5.1069644923041695
 5.027359768058255
 3.9201182037005156
 3.540353686844386
 ⋮
 0.8028207897693638
 0.2686124099144235
 0.14719116520460512
 0.775514076075816
 0.2734922240078289
 1.1517363032923782
 0.6121369166003804
 0.14338943272387059
 0.12355219408187865
 0.31931042124785247
 0.12613588954652152
 0.21495536395883624
In [28]:
replace!(Pvalue_mlog10, NaN => 0)
replace!(Pvalue_mlog10, Inf => 0)
Out[28]:
6643744-element Vector{Float64}:
 4.4864152898017755
 1.6223364430006184
 4.964844950013266
 3.6564302183607658
 4.764691914587121
 4.061765615443749
 4.597033250870413
 4.274961913153066
 3.3136752863405654
 5.1069644923041695
 5.027359768058255
 3.9201182037005156
 3.540353686844386
 ⋮
 0.8028207897693638
 0.2686124099144235
 0.14719116520460512
 0.775514076075816
 0.2734922240078289
 1.1517363032923782
 0.6121369166003804
 0.14338943272387059
 0.12355219408187865
 0.31931042124785247
 0.12613588954652152
 0.21495536395883624
In [29]:
maximum(Pvalue_mlog10)
Out[29]:
15.653559774527022
In [40]:
index = findall(x -> abs.(x) .> 10.0,Pvalue_mlog10)
Out[40]:
189403-element Vector{Int64}:
      38
      40
      46
     152
     153
     164
     223
     269
     290
     299
     313
     323
     353
       ⋮
 6641778
 6641779
 6641806
 6641808
 6641820
 6641824
 6641827
 6641838
 6641870
 6641915
 6641920
 6641922
In [41]:
sig_res = DataFrame(SNP1 = a[index], SNP2 = b[index], Pvalue_mlog10 = Pvalue_mlog10[index])
Out[41]:

189,403 rows × 3 columns

SNP1SNP2Pvalue_mlog10
Int64Int64Float64
145110.6154
247110.8235
356113.6082
4177113.0387
5178110.5531
6190111.4469
7251110.1679
8300113.1779
9326114.2918
10338114.0303
11356110.0445
12366111.533
13398110.7925
14403114.4775
15414110.973
16424114.6122
17425111.4831
18430110.4652
19457111.2527
20483111.5943
21491110.2782
22503111.388
23505110.7726
24509113.3131
25536110.1548
26541110.1989
27543110.5802
28544110.1989
29555110.8833
30628110.7951
⋮⋮⋮⋮
In [42]:
epistaticQTLPos = epistaticQTLPos[epi_combinations]
Out[42]:
3×2 Matrix{Int64}:
 2621  2263
 1037   287
  264  2131
In [43]:
trace1 = heatmap(z=sig_res.Pvalue_mlog10, x=sig_res.SNP1, y=sig_res.SNP2, colorscale="Viridis")
trace2 = scatter(x=epistaticQTLPos[:,1], y=epistaticQTLPos[:,2], mode="markers+text", textposition="top center",
                           text=[epistaticQTLPos[:,1] epistaticQTLPos[:,2]]')
trace3 = scatter(x=epistaticQTLPos[:,2], y=epistaticQTLPos[:,1], mode="markers+text", textposition="bottom center",
                           text=[epistaticQTLPos[:,2] epistaticQTLPos[:,1]]')
data = [trace1,trace2,trace3]
layout = Layout(xaxis_nticks=36, yaxis_title="SNPs2",xaxis_title="SNPs1", showlegend= false) 
myplot = PlotlyJS.plot(data,layout)
Out[43]:
In [44]:
savefig(myplot, "SNP_SNP_Pvalue.png")
Out[44]:
"SNP_SNP_Pvalue.png"
In [ ]: